<?php

declare(strict_types=1);
/**
 * 创建人 : Forpastime
 *
 * @link     http://hypercmf.com
 * @document https://hyperf.wiki
 * @contact  forpastime@qq.com
 * @git  https://gitee.com/hypercmf/hypercmf1.0.git
 */
namespace App\Command;

use App\Utils\RoutesToNodes;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Hyperf\Contract\ConfigInterface;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Input\InputOption;
/**
 * 将注解菜单放进node节点 参考vendor/hyperf/RoutesCommand.php
 * @Command
 */
#[Command]
class RoutesToNode extends HyperfCommand
{
    /**
     * @var ContainerInterface
     */
    protected $container;

    public function __construct(ContainerInterface $container, ConfigInterface $config)
    {
        $this->container = $container;

        parent::__construct('for:annotation-routes-to-node');
    }

    public function configure()
    {
        parent::configure();
        $this->setDescription('查看注解能生成的功能节点')
            ->addOption('path', 'p', InputOption::VALUE_OPTIONAL, '指定获取路由的目录，如 admin或api','admin')
            ->addOption('server', 'S', InputOption::VALUE_OPTIONAL, '服务类型：http/jsonrpc-http/jsonrpc', 'http');
    }

    public function handle()
    {
        //存库存缓存
        $res = RoutesToNodes::start();
        var_dump($res);
    }
}
